#ifndef HTTP_MU__PORT_H
#define HTTP_MU__PORT_H

#include <pthread.h>

#ifdef __cplusplus
extern "C" {
#endif


#define httpmu_thread_t pthread_t
#define httpmu_mutex_t pthread_mutex_t
#define httpmu_cond_t pthread_cond_t

#define httpmu_malloc(s) malloc(s)
#define httpmu_free(h) free(h)

#define httpmu_mutex_init(m) pthread_mutex_init(m, NULL)
#define httpmu_mutex_free(m) pthread_mutex_destroy(m)
#define httpmu_mutex_lock(m) pthread_mutex_lock(m)
#define httpmu_mutex_unlock(m) pthread_mutex_unlock(m)


#define httpmu_cond_init(c) pthread_cond_init(c, NULL)
#define httpmu_cond_free(c) pthread_cond_destroy(c)
#define httpmu_cond_wait(c, m) pthread_cond_wait(c, m)
#define httpmu_cond_timedwait(c, m, t) pthread_cond_timedwait(c, m, t)
#define httpmu_cond_signal(c) pthread_cond_signal(c)

#define httpmu_delay_sec(sec) sleep(sec)

#define httpmu_start_thread(id, thread_fun, arg) pthread_create(id, NULL, thread_fun, arg)
#define httpmu_stop_thread(id) do{pthread_cancel(id); pthread_join(id, NULL);} while(0)



#ifdef __cplusplus
}
#endif

#endif
